|
|
|
|
|
|
|
The syntax is basically the same for all three methods: |
|
|
|
|
|
|
|
|
object.GetData (format)
object.SetData [data], [format]
object.GetFormat (format) |
|
|
|
|
|
|
|
|
The SetData, GetData, and GetFormat methods use the data and format arguments either to return the type of data in the DataObject object or to retrieve the data itself if the format is compatible with the target. In the following example, data in a text box was selected and the format was specified as text (vbCFText). This text is stored in the DataObject so the target control (wherever it is) can retrieve it: |
|
|
|
|
|
|
|
|
Private Sub txtLastName_OLEStartDrag(Data As VB.DataObject,_
AllowedEffects As Long)
Data.SetData txtLastName.SelText, vbCFText
End Sub |
|
|
|
|
|
|
|
|
The OLEDrag method is usually executed from an object's Mousemove event. Its primary purpose is to initiate the start of a manual drag operation, which triggers the OLEStartDrag event. The OLEDrag method will only work if the object's OLEDragMode property has been set to Manual. |
|
|
|
|
|
|
|
|
Note If the control supports manual but not automatic OLE drag, it will not have the OLEDragMode property; however, it will still support the OLEDrag method and the OLE drag-and-drop events. |
|
|
|
|
|
|
|
|
|
When the OLEStartDrag event has been triggered, you will be able to specify which drop effects and data formats the source requires the target to support. The OLEStartDrag event has two arguments that indicate the supported data formats and whether the data can be copied or moved when data is dropped. |
|
|
|
|
|
|
|
|
Caution If you don't specify any drop effects or data formats in the OLEStartDrag event, the manual drag operation will not start. |
|
|
|
|
|
|
|
|
|
The allowed effects argument sets which drop effects the drag source control will support. This argument can be checked in the target control's OLEDragDrop event, and the program can respond based on the current settings. In addition, you can also specify |
|
|
|
|
|